<?php

declare(strict_types=1);
/**
 * This file is part of Sws.
 *
 * @link     https://gitee.com/sreeb/sws-dev.git
 * @document https://gitee.com/sreeb/sws-dev.git
 * @contact  https://gitee.com/sreeb/sws-dev.git
 * @license  https://gitee.com/sreeb/sws-dev/blob/master/LICENSE
 */
use sws\route\Route;

//路由目标参数支持字符串 @ 分割类和方法，数组，闭包。
Route::get('/', 'app\controllers\Index@index')->middleware(function (Swoole\Http\Request $request, $next) {
    return $next($request);
});

//路由参数绑定
Route::any('/test/{str:\S+}', [\app\controllers\Index::class, 'test'])->middleware(\app\middleware\TestMiddleware::class);

//分组路由。
//中间件执行顺序为全局中间件->路由分组中间件->路由中间件
Route::group('/group', function () {
    Route::get('/index', 'app\controllers\Index@index')->middleware(function (Swoole\Http\Request $request, $next) {
        return $next($request);
    });
})->middleware([\app\middleware\TestMiddleware::class]);
